<?php
/**
 * @name IndexController
 * @author root
 * @desc 默认控制器
 * @see http://www.php.net/manual/en/class.yaf-controller-abstract.php
 */
class IndexController extends \Yaf\Controller_Abstract {

    public function init()
    {
       // Yaf\Dispatcher::getInstance()->disableView();
    }
	/** 
     * 默认动作
     * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
     * 对于如下的例子, 当访问http://yourhost/Sample/index/index/index/name/root 的时候, 你就会发现不同
     */
	public function indexAction($name = "hxslcc") {
		//1. fetch query
		$get = $this->getRequest()->getQuery("get", "default value");

		//2. fetch model
		$model = new SampleModel();

		//3. assign
		$this->getView()->assign("content", $model->selectSample());
		$this->getView()->assign("name", $name);

		//4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
        return true;
	}

	public function testAction(){
	    $user_id = $this->getRequest()->get('userId');
	    echo "this is reg route test <br /> userId={$user_id}";
	    return false;
    }

    public function modelAction()
    {
        $post = PostModel::find(100);
        print_r($post->toArray());
        return false;
    }
}
